<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户信息查询</title>
    <link rel="stylesheet" href="./login.css">
    <script>
        function login() {
            window.location = "user.html";
        }
    </script>
</head>
<body>
    <div class="loginCard">
            <h1 >
                <style>
                    h1{
                        text-align: center;
                    }
                </style>
                用户信息
            </h1>
            <?php
                 header("Content-type:text/html;charset=utf-8");
                 $con = mysqli_connect("localhost", 'root', '', 'ksdb2');
                 mysqli_set_charset($con, "utf8");

                 $id = $_GET['id'];
                 $user=$_GET['user'];

                 if($user=='0'){
                    
                    $sql="select student_view.st_id,student_view.st_name,st_sex,dpt_name,mj_name,cl_name from student_view,student where student_view.st_id=student.st_id and student_view.st_id = '$id';";
                    $result = mysqli_query($con,$sql);
                    echo "<table border='1'><tr><th>学号</th>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>院系</th>
                        <th>专业</th>
                        <th>班级</th>
                        </tr>";
                    $row = mysqli_fetch_array($result);
                    echo "<tr>";
                    echo "<td>" . $row['st_id'] . "</td>";
                    echo "<td>" . $row['st_name'] . "</td>";
                    echo "<td>" . $row['st_sex'] . "</td>";
                    echo "<td>" . $row['dpt_name'] . "</td>";
                    echo "<td>" . $row['mj_name'] . "</td>";
                    echo "<td>" . $row['cl_name'] . "</td>";
                    echo "<tr>";
                 
                    echo "</table>";
                    
                }else if($user=='1'){
                    $sql="call pro_grade('$id');";
                    $result = mysqli_query($con,$sql);

                    echo "<table border='1'><tr><th>学号</th>
                    <th>姓名</th>
                    <th>课程号</th>
                    <th>课程</th>
                    <th>成绩</th>
                    
                    </tr>";
                    while($row = mysqli_fetch_array($result)){
                        
                            echo "<tr>";
                            echo "<td>" . $row['st_id'] . "</td>";
                            echo "<td>" . $row['st_name'] . "</td>";
                            echo "<td>" . $row['cs_id'] . "</td>";
                            echo "<td>" . $row['cs_name'] . "</td>";
                            echo "<td>" . $row['sc_grade'] . "</td>";
                            
                            echo "<tr>";
                    }
                    echo "</table>";
                }else if($user=='2'){
                    $sql="select cl_id, cl_name, mj_name, dpt_name, cl_number from class, major, department where class.mj_id = major.mj_id and major.dpt_id = department.dpt_id and class.cl_id = '$id';";
                    $result = mysqli_query($con,$sql);

                    echo "<table border='1'>
                    <th>班级号</th>
                    <th>班级名</th>
                    <th>专业名</th>
                    <th>系名</th>
                    <th>班级人数</th>
                    
                    </tr>";
                    while($row = mysqli_fetch_array($result)){
                        
                            echo "<tr>";
                            echo "<td>" . $row['cl_id'] . "</td>";
                            echo "<td>" . $row['cl_name'] . "</td>";
                            echo "<td>" . $row['mj_name'] . "</td>";
                            echo "<td>" . $row['dpt_name'] . "</td>";
                            echo "<td>" . $row['cl_number'] . "</td>";
                            
                            echo "<tr>";
                    }
                    echo "</table>";
                }else if($user=='3'){
                    $sql="select major.mj_id, mj_name, dpt_name, cl_name from class, major, department where major.dpt_id = department.dpt_id and class.mj_id = major.mj_id and major.mj_id = '$id';";
                    $result = mysqli_query($con,$sql);

                    echo "<table border='1'>
                    <th>专业号</th>
                    <th>专业名</th>
                    <th>系名</th>
                    <th>班级名</th>
                    
                    </tr>";
                    while($row = mysqli_fetch_array($result)){
                        
                            echo "<tr>";
                            echo "<td>" . $row['mj_id'] . "</td>";
                            echo "<td>" . $row['mj_name'] . "</td>";
                            echo "<td>" . $row['dpt_name'] . "</td>";
                            echo "<td>" . $row['cl_name'] . "</td>";
                            
                            echo "<tr>";
                    }
                    echo "</table>";
                }else if($user=='4'){
                    $sql="select department.dpt_id, dpt_name, mj_name from major, department where major.dpt_id = department.dpt_id and department.dpt_id = '$id';";
                    $result = mysqli_query($con,$sql);

                    echo "<table border='1'>
                    <th>系号</th>
                    <th>系名</th>
                    <th>专业名</th>
                    
                    </tr>";
                    while($row = mysqli_fetch_array($result)){
                        
                            echo "<tr>";
                            echo "<td>" . $row['dpt_id'] . "</td>";
                            echo "<td>" . $row['dpt_name'] . "</td>";
                            echo "<td>" . $row['mj_name'] . "</td>";
                            
                            echo "<tr>";
                    }
                    echo "</table>";
                }else if($user=='5'){
                    $sql="select ap_id, dpt_name, mj_name, student.st_id, st_name, ap_project, ap_name from student, award_punish, major, department, class where student.st_id = award_punish.st_id and student.cl_id = class.cl_id and class.mj_id = major.mj_id and major.dpt_id = department.dpt_id and student.st_id = '$id';";
                    $result = mysqli_query($con,$sql);

                    echo "<table border='1'>
                    <th>奖惩号</th>
                    <th>系名</th>
                    <th>专业名</th>
                    <th>学号</th>
                    <th>姓名</th>
                    <th>奖惩方案</th>
                    <th>奖惩名</th>

                    </tr>";
                    while($row = mysqli_fetch_array($result)){
                        
                            echo "<tr>";
                            echo "<td>" . $row['ap_id'] . "</td>";
                            echo "<td>" . $row['dpt_name'] . "</td>";
                            echo "<td>" . $row['mj_name'] . "</td>";
                            echo "<td>" . $row['st_id'] . "</td>";
                            echo "<td>" . $row['st_name'] . "</td>";
                            echo "<td>" . $row['ap_project'] . "</td>";
                            echo "<td>" . $row['ap_name'] . "</td>";
                            
                            echo "<tr>";
                    }
                    echo "</table>";
                }
                 
 
	             mysqli_close($con);
            ?>
            
            <br>
            
            <div>
                
                <button type="button" onclick="login()">返回</button>
                
            </div>
            
            